package org.hot100_3;

import java.util.ArrayList;
import java.util.List;

public class leetcode234 {
    public boolean isPalindrome(ListNode head) {

        List<Integer> listArray = new ArrayList<>();

        ListNode temp = head;

        while (temp != null) {
            listArray.add(temp.val);
            temp = temp.next;
        }

        int left = 0;
        int right = listArray.size() - 1;

        while (left<right){
            if (listArray.get(left)!=listArray.get(right)){
                return false;
            }
            left++;
            right--;
        }

        return true;
    }
}
